import { util } from '../../../../utils/util'
var app = getApp();
//不良记录页面
Page({
  mixins: [],
  data: {
     activityType:'',    //活动类型
     instanceType:'',       //实例类型
      stateText:'',
     currdate : util.formatDateTime(new Date()),
     honorFiles:[], //图片数组
    },

    onSubmit(e) {
      var me = this;
      var obj = e.detail.value;
      var dataObj=obj;
      //做非空校验
      if(util.validation(dataObj)){
          obj['files'] = me.data.honorFiles;
          obj['activityType'] = parseInt(me.data.activityType);
          obj['instanceType'] = parseInt(me.data.instanceType);
          obj['showName'] = 'punishmentName';
          console.log("__________))))))))))))))_____________")
          var data = {
              activityType: parseInt(me.data.activityType),
              instanceType: parseInt(me.data.instanceType),
              itemInfo : obj,
          }
         //提交数据
          util.submitRecord(data);
      } 
    },

  stateDatePickerYMDHMS() {
    dd.datePicker({
      format: 'yyyy-MM-dd',
      currentDate: this.data.currdate,
      startDate: util.formatDateTimeFive(new Date()),
      endDate: this.data.currdate,
      success: (res) => {
        this.setData({
          stateText : res.date
        });
      }
    });
  },
  
  
  onLoad(query) {
    // 页面加载
    console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
     var arr = query.honorFiles.split(",");
    this.setData({
      activityType: query.activityType,
      instanceType: query.instanceType,
      honorFiles: arr,
    });
  },
  onUnload() {
    // 页面被关闭
    wx.setStorageSync("honorFiles", []);
  },
});
